#include <iostream>
#include <sstream>
#include <string>
#include <memory>
#include <jsoncpp/json/json.h>

int main()
{
    const char *name = "小连";
    int age = 18;
    float score[] = {90, 78.5, 86.3};

    Json::Value root;
    root["姓名"] = name;
    root["年龄"] = age;

    root["成绩"].append(score[0]);
    root["成绩"].append(score[1]);
    root["成绩"].append(score[2]);

    Json::StreamWriterBuilder swb;
    // 设置 emitUTF8 使其输出原始的 UTF-8 编码而不是转义序列
    swb["emitUTF8"] = true;
    std::unique_ptr<Json::StreamWriter> sw(swb.newStreamWriter());
    std::stringstream ss;
    sw->write(root, &ss);

    std::cout << ss.str() << std::endl;

    return 0;
}